package com.zzk.lanouhn.myapplication1.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.jude.rollviewpager.adapter.StaticPagerAdapter;
import com.squareup.picasso.Picasso;
import com.zzk.lanouhn.myapplication1.modles.Adpic;

/**新闻界面轮播图适配器
 * Created by lanouhn on 16/8/24.
 */
public class RollViewPagerAdapter extends StaticPagerAdapter{
    private Context context;
    private Adpic adpic;

    public RollViewPagerAdapter(Context context, Adpic adpic) {
        this.context = context;
        this.adpic = adpic;
    }

    @Override
    public View getView(ViewGroup container, int position) {
        ImageView view =new ImageView(container.getContext());
        Picasso.with(context).load(adpic.getData().getPics().get(position).getImgUrl()).into(view);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
        return view;
    }

    @Override
    public int getCount() {
        return adpic.getData().getPics().size();
    }
}
